class LocalCache {
  setItem(key, value) {
    window.localStorage.setItem(key, JSON.stringify(value))
  }

  getItem(key) {
    const cache = window.localStorage.getItem(key) ? window.localStorage.getItem(key) : null
    if (cache === null) return cache
    return JSON.parse(cache)
  }

  deleteItem(key) {
    window.localStorage.removeItem(key)
  }

  clearItem() {
    window.localStorage.clear()
  }
}

export default new LocalCache()
